package com.example.testcourse3;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class InputNumberServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        GuessGame game = new GuessGame();
        System.out.println("InputNumberServlet random number："+game.getRandomNumber());
        request.getSession().setAttribute("game", game); // 在session中保存游戏状态
        RequestDispatcher view = request.getRequestDispatcher("/guess.jsp");
        view.forward(request, response);
    }

}
